package com.scuec.groupfive.controller;

import com.scuec.groupfive.dto.ExamScoreStatsDTO;
import com.scuec.groupfive.service.ExamScoreStatsService;
import com.scuec.groupfive.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
public class ExamScoreStatsController {
    @Autowired
    private ExamScoreStatsService examScoreStatsService;

    @GetMapping("/score-distribution")
    public Result<List<ExamScoreStatsDTO>> getScoreDistributionByExamType(
            @RequestParam(value = "examType", required = false, defaultValue = "all") String examType) {
        List<ExamScoreStatsDTO> stats = examScoreStatsService.getScoreDistributionByExamType(examType);
        return Result.success(stats);
    }
}